package com.qf.fmcommodity.user.controller;

import com.qf.fmcommodity.user.entity.Category;
import com.qf.fmcommodity.user.entity.IndexImg;
import com.qf.fmcommodity.user.entity.Product;
import com.qf.fmcommodity.user.service.ICategoryService;
import com.qf.fmcommodity.user.service.IIndexImgService;
import com.qf.fmcommodity.user.service.IProductService;
import com.qf.fmcommodity.user.vo.LoginVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 轮播图  前端控制器
 * </p>
 *
 * @author 苇名一心
 * @since 2023-02-13
 */
@RestController
@RequestMapping("/index")
@CrossOrigin
public class IndexController {

    @Autowired
    ICategoryService iCategoryService;

    @Autowired
    IIndexImgService iIndexImgService;

    @Autowired
    IProductService iProductService;



    /**
     * 商品分类
     * @return
     */
    @RequestMapping("/category-list")
    public LoginVo categoryList(){

        List<Category> data = iCategoryService.getAll();

        LoginVo vo = new LoginVo();

        vo.put("data",data);

        return vo;
    }


    /**
     * 轮播图
     * @return
     */
    @RequestMapping("/indeximg")
    public LoginVo indeximg(){
        List<IndexImg> data =  iIndexImgService.getIndeximg();

        LoginVo vo = new LoginVo();
        vo.put("data",data);

        return vo;
    }

    @GetMapping("/list-recommends")
    public LoginVo listRecommends(){

        List<Product> data =  iProductService.listRecommends();

        LoginVo vo = new LoginVo();
        vo.put("data",data);

        return vo;

    }



    @GetMapping("/category-recommends")
    public LoginVo categoryRecommends(){

        List<Category> data =  iCategoryService.ccategoryRecommends();

        LoginVo vo = new LoginVo();
        vo.put("data",data);

        return vo;

    }

}
